

Ext.define('scribbles.ViewArticleWidget',{
	extend: 'Ext.form.Panel',
	alias: 'widget.ViewArticleWidget',
	autoShow: true, 
	store: new Ext.data.Store({
		model: 'ArticleHeader', 
		proxy: {
			type: 'ajax', 
			reader: {
				type: 'json', 
				root: 'articleHeader'
			}
		}
	}), 
	height: 600,
	layout: 'anchor', 
	items: [
		{
			xtype: 'displayfield', 
			name: 'name', 
			anchor: '100%'
		}	
	], 
    loadArticleHeader : function(articleHeaderId) {
    	alert('loading article' + articleHeaderId);
    	this.store.proxy.url = 'article/loadArticleHeader/' + articleHeaderId + '.json';
    	this.store.load({
    	    scope   : this,
    	    callback: function(storeRef, records, operation, success) {
				var articleHeaderModel = this.store.getAt(0).data;
				alert('articleHeaderModelsssssss.name: ' + articleHeaderModel.name);
				 //var form = this.up('form').getForm();
				//alert('this.getForm()' + this.getForm().findField("name"));
				this.getForm().findField("name").setValue(articleHeaderModel.name);
    	    }
    	});
    	
    	Ext.Ajax.request({
    	    url: 'article/getArticlesList/' + articleHeaderId + '.json',
    	    success: function(response){
    	        var text = response.responseText;
    	        // process server response here
    	    }
    	});
    }
});